package lion.project.blackboard_for_education;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Display;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;

public class BlackboardForEducationActivity extends Activity {
	DrawView drawView;
	
    private static final int MENU_COLOR = 0;
	private static final int MENU_CLEAR = 1;
    private static final int MENU_SAVE = 2;
	private static final int MENU_LINE = 3;
	private static final int MENU_ITEM = 4;
	private static final int MENU_BLOCK = 5;
	// 描画オブジェクト
	private static final int LINE_OBJECT = 0;
	private static final int OHAZIKI_OBJECT = 1;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

        drawView = new DrawView(getApplication(), null);
        //setContentView(R.layout.main);
        setContentView(drawView);
    }
    
    @Override
	protected void onDestroy() {
		super.onDestroy();
		if(drawView != null){
			// Bitmapの解放
			drawView.mOhazikiImg.recycle();
		}
		drawView = null;
	}
    
    /** メニューの生成イベント */
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    	super.onCreateOptionsMenu(menu);
    	menu.add(0, MENU_LINE, 0, "手書き");
    	menu.add(0, MENU_ITEM, 0, "おはじき");
    	menu.add(0, MENU_COLOR, 0, "いろ");
    	menu.add(0, MENU_CLEAR, 0, "消す");
    	menu.add(0, MENU_SAVE, 0, "ほぞん");
    	menu.add(0, MENU_BLOCK, 0, "文字ブロック");
    	return true;
    }
    /** メニューがクリックされた時のイベント */
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	switch ( item.getItemId() ) {
    	case MENU_LINE:
    		drawView.setObjectToDraw(LINE_OBJECT);
    		break;
    	case MENU_ITEM: // TODO
    		drawView.setObjectToDraw(OHAZIKI_OBJECT);
    		break;
    	case MENU_COLOR:
            drawView.setColor(Color.GREEN);
            break;
    	case MENU_CLEAR:// TODO
    		//drawNoteView.clearDrawList();
    		break;
    	case MENU_SAVE: // TODO
    		break;
    	case MENU_BLOCK: // TODO
    		Intent intent = new Intent(getApplicationContext(),inputViewActivity.class);
    		startActivity(intent);
    		break;
    	}
    	return true;
    }
}